/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package service;

import java.util.List;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import model.Carro;

/**
 *
 * @author Omar
 */
@Stateful
public class CarroFacade implements CarroFacadeRemote {
    @PersistenceContext(unitName="CarroPU")
    private EntityManager em;

    @Override
    public void create(Carro carro) {
        em.persist(carro);
    }

    @Override
    public void remove(Carro carro) {
        em.remove(em.merge(carro));
    }

    @Override
    public Carro find(Object id) {
         return em.find(Carro.class, id);
    }

    @Override
    public List<Carro> findAll() {
      return em.createQuery("select object(o) from Carro as o").getResultList();
    }

    
}
